package com.example.demo.event.guava;

import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.async.DeferredResult;

/**
 * 送积分
 * @author lyc
 * @date 2019/6/10.
 */
@Component
@Slf4j
public class IntegralEventListener {

    @Subscribe
    public void listen(UserRegisterEvent event){
        //送积分
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {

        }
        log.info("送积分: "+event.getMessage());
    }

    @Subscribe
    public void listen(DeferredResult event){
        //送积分
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {

        }
        event.setResult("ok");
        log.info("异步结果响应: ");
    }

    @Subscribe
    public void listen(String message){
       log.info("receive message: "+message);
    }

}